<%@page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F8F9FA;
}
-->
</style>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="<%=syscontextPath %>/images/mail_leftbg.gif"><img src="<%=syscontextPath %>/images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="<%=syscontextPath %>/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">商品信息</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="<%=syscontextPath %>/images/mail_rightbg.gif"><img src="<%=syscontextPath %>/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="<%=syscontextPath %>/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
           <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
            <form id="form1" method="post" action="<%=syscontextPath %>/product/upload3" enctype="multipart/form-data">
            	<c:choose>
							<c:when test="${product ==null}">
								<input type="hidden" name="id"  id="id" value="0">
								<input type="hidden" name="openmethod"  id="openmethod" value="0">
							</c:when>
							<c:otherwise>
								<input type="hidden" name="id"  id="id" value="${product.id}">
								<input type="hidden" name="openmethod"  id="openmethod" value="${product.openmethod} }">
							</c:otherwise>
						</c:choose> 
                <table width="100%" height="90" border="0" cellpadding="0" cellspacing="0">
                  <tr bgcolor="#f2f2f2">
                    <td align="center" class="left_txt">&nbsp;</td>
                    <td class="left_txt">&nbsp;</td>
                    <td rowspan="5" class="left_txt">
                    <div style="width:120px;height:90px;overflow:hidden;border:dotted 1px #ccc" id="fileInputprv">
                    <c:if test="${product !=null}"><img src="<%=syscontextPath %>/upload/images/${product.companyid}/${product.type}/${product.flag}/${product.image}_1.jpg"> </c:if>
                    </div>
                    </td>
                  </tr>
                  
                  <tr>
                    <td align="right"  class="left_txt">系列：</td>
                    <td  class="left_txt">
                      <select name="type" id="serytype">
                        <option value='0'>请选择</option>
                        </select>
                    </td>
                  </tr>
                  <tr bgcolor="#f2f2f2">
                    <td align="right"  class="left_txt">所属类型：</td>
                    <td  class="left_txt">
                      <select name="flag" id="flag">
                        <option value='0' <c:if test="${product.flag==0}">selected='true'</c:if>>请选择</option>
                        <option value='1' <c:if test="${product.flag==1}">selected='true'</c:if>>平开门</option>
                        <option value='2' <c:if test="${product.flag==2}">selected='true'</c:if>>单推拉</option>
                        <option value='3' <c:if test="${product.flag==3}">selected='true'</c:if>>双推拉门</option>
                        <option value='4' <c:if test="${product.flag==4}">selected='true'</c:if>>对开门</option>
                        <option value='5' <c:if test="${product.flag==5}">selected='true'</c:if>>子母门</option>
                        <option value='6' <c:if test="${product.flag==6}">selected='true'</c:if>>三推拉</option>
                        <option value='7' <c:if test="${product.flag==7}">selected='true'</c:if>>四推拉</option>
                        <option value='8' <c:if test="${product.flag==8}">selected='true'</c:if>>折叠门</option>
                        <option value='9' <c:if test="${product.flag==9}">selected='true'</c:if>>单边套</option>
                        <option value='10' <c:if test="${product.flag==10}">selected='true'</c:if>>双边套</option>
                        <option value='11' <c:if test="${product.flag==11}">selected='true'</c:if>>不规则套</option>
                        </select>
                    </td>
                  </tr>
                  <tr >
                    <td align="right" class="left_txt">产品名称：</td>
                    <td class="left_txt"><input type="text" name="productname" id="productname" value="${product.productname}" size="30" class="button01" /></td>
                  </tr>
                  <tr bgcolor="#f2f2f2">
                    <td align="right" class="left_txt">产品编号：</td>
                    <td class="left_txt"><input type="text" name="productno" id="productno" value="${product.productno}" size="30" class="button01" /></td>
                  </tr>
                  <tr>
                    <td align="right" class="left_txt">油漆工艺：</td>
                    <td class="left_txt"><input type="text" name="painttech" id="painttech" value="${product.painttech}" size="30" class="button01" /></td>
                  </tr>
                  <tr bgcolor="#f2f2f2">
                    <td align="right" bgcolor="#f2f2f2" class="left_txt">价格：</td>
                    <td bgcolor="#f2f2f2" class="left_txt">
                    <input type="text" name="price" id="price" value="${product.price}" size="30" class="button01" /></td>
                  </tr>
                  <tr >
                   	<td align="center" class="left_txt"> &nbsp;</td>
                    <td align="center" class="left_txt">
                      <input type="file" name="fileInput" id="fileInput" value="上传图片">&nbsp;&nbsp;
                    </td>
                    <td align="center" class="left_txt"> &nbsp;</td>
                  </tr>
                  <tr bgcolor="#f2f2f2">
                    <td colspan="3" align="center" class="left_txt">
                      <input type="button"  id="saveform" value="确定">&nbsp;&nbsp;
                      <input type="reset" name="resetform" id="button"  onclick="close_win();" value="关闭">
                    </td>
                    </tr>
                </table>
                </form>
             </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>
    <td background="<%=syscontextPath %>/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="<%=syscontextPath %>/images/mail_leftbg.gif"><img src="<%=syscontextPath %>/images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="<%=syscontextPath %>/images/buttom_bgs.gif"><img src="<%=syscontextPath %>/images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="<%=syscontextPath %>/images/mail_rightbg.gif"><img src="<%=syscontextPath %>/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>

</body>
<script type="text/javascript">
<!--
$(function (){
	//系列
	$.getJSON("<%=syscontextPath %>/basicinfo/findProductSeryList/0",function(data){
		var html = "",selectsery = "${product.type}";
		jQuery.each(data,function(i,item){
			if(item.id == selectsery){
				html += "<option value='"+item.id+"' selected='true'>"+item.name+"</option>";
			}else{
				html += "<option value='"+item.id+"'>"+item.name+"</option>";
			}	
		});
		$("#serytype").append(html);
	});

	//所属类型
	//$.getJSON("<%=syscontextPath %>/basicinfo/findProductTypelist/0",function(data){
	//	var html = "",flagid = "${product.flag}";
	//	jQuery.each(data,function(i,item){
	//		if(item.id == flagid){
	//			html += "<option value='"+item.id+"' selected='true'>"+item.name+"</option>";
	//		}else{
	//			html += "<option value='"+item.id+"'>"+item.name+"</option>";
	//		}	
	//	});
	//	$("#flag").append(html);
	//});
});

$("#saveform").click(function (){
	if (checkform()) {
		$("#form1").submit();
		}
});

/**
 * 检查form
 */
function checkform() {
	var productname = $("#productname").val();
	var painttech = $("#painttech").val();
	var price = $("#price").val();
	if (productname == "") {
		alert("商品名称不能为空");
		return false;
	}
	if (painttech == "") {
		alert("油漆工艺不能为空");
		return false;
	}
	if (price == "" || isNaN(price)) {
		alert("价格不正确");
		return false;
	}
	return true;
}

$("#fileInput").change(function() {
	var imgObj='fileInput';
	  // 这里可以写些验证代码
	jQuery.imagePreview({id:imgObj+'prv',upload:imgObj,preObj:imgObj+'prv',width:120,height:90});
});
//-->
</script>
